import {
  renderHouseInfo,
  addEventListener,
  renderJjrInfo,
} from "../../common/render";
import { initScene } from "../../common/scene";
import {
  formatHouseInfo,
  formatUrl,
  initDevelop,
  requestAjax,
  shareVr,
} from "../../common/utils";
require("../css/index.css");
(function ($) {
  initDevelop().then(() => {
    window.watermark_image = "images/shulan_logo.png";

    addEventListener();

    Resources.path.logo = window.watermark_image;

    initScene({
      from: "3d",
      access: formatUrl.getQuery("access"),
    });

    requestAjax({
      url: "/shulan-jjr-gateway/api/v1/hou/panoInfo",
      data: {
        delId: formatUrl.getQuery("houDelId"),
      },
    }).then(({ content }) => {
      runVRHouseApp(content);
    });

    // 获取房源信息
    requestAjax({
      url: "/shulan-jjr-gateway/api/v1/hou/getAgentAndDelInfo",
      contentType: "application/x-www-form-urlencoded",
      type: "post",
      data: {
        delId: formatUrl.getQuery("houDelId"),
      },
    }).then((res) => {
      if (res.isSuccess) {
        const content = formatHouseInfo(res.content);

        shareVr(content);
        renderHouseInfo(content);
        renderJjrInfo(content);
      }
    });
  });
})(jQuery);
